// 药房管理
<template comments>
  <div class="pharmacy">
    <TopManu :signOut="true" @handleQuit="$router.go(-1)"></TopManu>

    <div class="search">
      <div class="s1">
        <el-input v-model="params.keyword" placeholder="请输入名称"></el-input>
        <el-button @click="searchB()">查询</el-button>
      </div>
      <div class="selectBai">
       

        <div>
          <el-date-picker
            @change="searchB"
            v-model="params.start_time"
            type="daterange"
            value-format="yyyy-MM-dd"
            start-placeholder="就诊时间"
            end-placeholder="就诊时间"
          >
          </el-date-picker>
        </div>
      </div>
    </div>

    <div class="tablesB">
      <el-table highlight-current-row v-loading="params.loading" :data="mz_statistics_list.list" border    @current-change="handleCurrentClick">
        <el-table-column type="index" width="70" label="序号">
        </el-table-column>
        <template v-for="(item, index) in tableTitle">
          <el-table-column
            :width="item.width"
            v-if="item.prop == 'member_info.gender'"
            :prop="item.prop"
            :label="item.label"
            :key="index"
          >
            <template slot-scope="scope">
              <div v-if="scope.row.member_info">
                {{
                  $baseBai["gender"].find(
                    (v) => v.value == scope.row.member_info.gender
                  ).label
                }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            :width="item.width"
            v-else-if="item.prop == 'look_type'"
            :prop="item.prop"
            :label="item.label"
            :key="index"
          >
            <template slot-scope="scope">
              <div>
                {{
                  scope.row.look_type
                    ? scope.row.look_type == 1
                      ? "初诊"
                      : "复诊"
                    : "--"
                }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            :width="item.width"
            v-else-if="item.prop == 'is_infect'"
            :prop="item.prop"
            :label="item.label"
            :key="index"
          >
            <template slot-scope="scope">
              <div>
                {{
                  scope.row.is_infect
                    ? scope.row.is_infect == 1
                      ? "是"
                      : "否"
                    : "--"
                }}
              </div>
            </template>
          </el-table-column>
          <el-table-column
            v-else
            :width="item.width"
            :prop="item.prop"
            :label="item.label"
            :key="index + item"
          >
          </el-table-column>
        </template>
      </el-table>
      <div>
        <el-pagination
          class="fenye"
          :background="true"
          :current-page="params.page"
          :page-size="params.limit"
          layout="prev, pager, next"
          @current-change="handlePagination"
          :total="params.pageCount"
        >
        </el-pagination>
      </div>
    </div>

    <!-- //$baseBai["hospitalization"]['mz_log_list'] -->
        <el-dialog title="处方信息" :visible.sync="params.show">
            <el-table :data="cfData">
                

                  <el-table-column type="index" width="70" label="序号">
        </el-table-column>
        <template v-for="(item, index) in cf_tabkeTitle">
                    <el-table-column
                   
                    :width="item.width"
                    :prop="item.prop"
                    :label="item.label"
                    :key="index + item"
                >
                </el-table-column>
        </template>
            </el-table>
        </el-dialog>

  </div>
</template>

<script>
let t;

import TopManu from "@/components/TopMenu";
import { mapState, mapActions } from "vuex";

export default {
  name: "mz_log",
  data() {
    return {
      tableTitle: this.$baseBai["hospitalization"]["mz_statistics_list"],
      cf_tabkeTitle:this.$baseBai["hospitalization"]["mz_statistics_cf_list"],
      params: {
        show:false,
        loading: false,

        page: 1,
        limit: 10,
        keyword: "",
        pageCount: 0,
        start_time:'',
      },

      data: [],
       cfData: [],
    };
  },
  components: {
    TopManu,
  },
  computed: {
    ...mapState({
      mz_statistics_list: (state) => {
        return state.doctorWorkStation.mz_statistics_list;
      },
    }),
  },
  mounted() {
    t = this;

    this.getList();
  },
  methods: {
    ...mapActions(["doctorWorkStation/getStatisticClinicOrderList"]),
    handleCurrentClick(val){
        console.log("val",val)
        
        let d={
            id:val.id
        }
         t["_API"].getClinic_doctorGetRecipeItem(d).then(res=>{
             console.log("res",res)

             if(res.code==200){
                  this.cfData=res.data.drug.map(v=>{
                      return {
                          ...v,
                          laiyuan:'医生录入',
                      }
                  });
                  this.params.show=true;
             }
            
         })
    },
    resetSearchB() {
      this.params = {
        loading: false,

        page: 1,
        limit: 10,
        keyword: "",
        start_time:'',
        pageCount: 0,
      };
      this.getList();
    },

    searchB() {
      t.params.page = 1;
      t.getList();
    },

    handlePagination(e) {
      t.params.page = e;
      t.getList();
    },
    getList() {
      let d = {
        keyword: t.params.keyword,
        limit: t.params.limit,
        page: t.params.page,
        time:this.params.start_time ? ((this.params.start_time.toString()).replace(',', '|')).toString() : '',
     
      };
      t.data = [];
      this.params.loading = true;
      this["doctorWorkStation/getStatisticClinicOrderList"](d).then((res) => {
        this.params.loading = false;
        this.params.pageCount = this.mz_statistics_list.count;
        console.log("mz_statistics_list", this.mz_statistics_list);
      });
    },
  },
};
</script>

<style lang="scss" scoped>
/deep/ .el-tabs__nav {
  .el-tabs__item {
    border-bottom: 1px solid #e4e7ed;
  }
  .is-active {
    color: #02bf6b;
  }
  .el-tabs__item:hover {
    color: #02bf6b;
  }
}
.search {
  border: 1px solid #f2f2f2;
  margin: 10px 2%;
  padding: 20px 20px 0;
  border-radius: 10px;
  .s1 {
    width: 400px;
    display: flex;
    button {
      margin-left: 20px;
      margin-bottom: 20px;
      background-color: #02bf6b;
      color: white;
    }
  }
  .selectBai {
    display: flex;
    > div {
      margin-right: 10px;
    }
  }
}

.tableMore {
  /deep/ .el-button--primary {
    color: black;
    background-color: initial;
    border-color: #e2e2e2;
  }
}
.tablesB,
.tabsB {
  margin: 20px 2% 0;
}

.fenye {
  text-align: right;
  margin-top: 20px;
  margin-bottom: 50px;
}
/deep/ .el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: #02bf6b;
}

/deep/ .el-dialog__body {
  // height: 70vh;
  overflow: scroll;
}
/deep/ .el-table td, .el-table th{
    padding: 8px 0;
}
/deep/ .el-dialog{
    width: 70%;
}
</style>